package client.skills;

import tools.CaltechEval;
import java.util.HashMap;
import java.util.Map;

/**
 *
 * @author T-Sun
 * 
 *   This file was written by T-Sun (doomgate17@naver.com)
 *
 *
 */
public class SkillStats {
    private final int level;
    private final Map <String, Integer> stats = new HashMap<String, Integer>();
    
    public SkillStats(int skilllevel) {
        this.level = skilllevel;
    }
    public final void setStats(String name, int value) {
        if (stats.containsKey(name)) {
            stats.remove(name);
        }
        stats.put(name, value);
    }
    
    public final void setStats(final String name, final String fomular) {
        if (stats.containsKey(name)) {
            stats.remove(name);
        }
        if (fomular != null) {
            int result = (int) (new CaltechEval(fomular.replace("x", level+"")).evaluate());
            stats.put(name, result);
        }
    }
    public final int getStats(String key) {
        if (stats.containsKey(key)) {
            return stats.get(key);
        }
        return SkillEffectDefaultValues.getDef(key);
    }
}

